package org.penguin.study.bk.mq.controller;

import org.penguin.study.bk.base.api.Return;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mq/redis")
public class RedisMessageController {

    private StringRedisTemplate redisTemplate;

    @GetMapping("/publish")
    public Return<?> publishMessage(@RequestParam(name = "message", defaultValue = "Redis Message入门经典!") String message) {
        redisTemplate.convertAndSend("chat", message);

        // receiver.getLatch().await(10000, TimeUnit.MILLISECONDS);
        return Return.Companion.ok("成功给RabbitMQ发消息");
    }
}
